/**
author: sailing
date: 2016/11/21
****/
<style lang='less'>
.container{
  margin:auto 0;
  position:relative;
  width: 100%;
  height:100%;	
  .containerApp{
    width:100%;
    height:100%;
    min-width:1000px;
    min-height:800px;
    transition:margin-left 1s ease 0s;
    position:absolute;
  }
}
</style>
<template>
  <div class="container">
    <search></search>
    <toolbar></toolbar>
    <div v-bind:style="{marginLeft: marginLeft + 'px'}" class="containerApp" id="containerApp">
    </div>
  </div>
</template>

<script>
import toolbar from './toolbar'
import search from './search'
import eventBus from '../eventBus'
import dataC from '../server/data'
import drawTopo from '../server/drawTopo'
import getPort from '../server/getPort'
import linkLine from '../server/linkLine'
import shortPath from '../server/shortPath'
import setNodePath from '../server/setNodePath'
import selectPort from '../server/selectPort'  
import disLabelIp from '../server/disLabelIp'
import filterLine from '../server/filterLine'
import excepPort from '../server/excepPort'
export default {
  data () {
    return {
      marginLeft: 5 
    }
  },
  components: {
    toolbar,
    search
  },
  methods: {
    checkedData () {
    }
  },
  mounted () {
    const that = this
    eventBus.bus.$on('getPortData', function (data) {
      getPort.start(that, data)
    })

    eventBus.bus.$on('linkLine', function (data) {
      linkLine.start(that, data)
    })

    eventBus.bus.$on('refreshAllNodes', function (data) {
      // console.log()
      drawTopo.refresh(data)
    })

    eventBus.bus.$on('changeDT', function (data) {
      drawTopo.draw()
    })

    eventBus.bus.$on('hideDistribution', function (data) {
      drawTopo.hideDistribution(data)
    })

    eventBus.bus.$on('excepPort', function (data) {
      excepPort.setPort(that, data)
    })

    eventBus.bus.$on('getNodePathArr', function (data) {
      setNodePath.start(that, data)
    })

    eventBus.bus.$on('getNodePath', function (data) {
      shortPath.start(that, data)
    })
    eventBus.bus.$on('clearSelect', function (data) {
      selectPort.clear(that, data)
    })

    eventBus.bus.$on('save_topo', function (data) {
      drawTopo.saveTopo(that, data)
    })

    eventBus.bus.$on('filterLine', function (value) {
      filterLine.filter(that, value)
    })
    
    eventBus.bus.$on('displayLabelIp', function (data) {
      disLabelIp.change(that)
    })

    eventBus.bus.$on('leftClose', function (data) {
      console.log('data:', data)
      if (data.flag) {
        that.marginLeft = 180
      } else {
        that.marginLeft = 0
      }
      setTimeout(function () {
        dataC.cy.resize()
        console.log('dataC:', dataC.cy)
      }, 2000)
    })
  }
}

</script>